<template>
  <span v-if="icon"><i :class="iconClass" /></span>
  <span v-else-if="file"><a
    :href="label"
    title="下载"
  >下载</a></span>
  <span v-else> {{ label }} </span>
</template>

<script>
/**
 * 用于表格的单元格
 */
// import { FIELD_INPUT } from '../../store/Form'

export default {
  props: {
    col: {
      type: Object,
      default: () => null
    },
    value: {
      type: [String, Number, Boolean],
      default: null
    }

  },
  computed: {
    label () {
      // switch
      if (this.col.activeText) {
        return this.value ? this.col.activeText : (this.col.inactiveText || '否')
      }

      // 有选项
      // if (FieldPicker(this.tag).items) {
      //   return this.items.find(item => item.value === this.value).label
      // }
      //
      return this.value
    },
    file () {
      return this.col.monitor === 'file'
    },
    iconClass () {
      return this.value ? this.icon.active : this.icon.inactive
    },

    icon () {
      return this.col.icon
    }
  }
}

</script>

<style scoped>

</style>
